FROM golang:1.20.13-alpine3.19 AS builder

# 为我们的镜像设置必要的环境变量
ENV GO111MODULE=on \
    GOPROXY=https://goproxy.cn,direct \
    CGO_ENABLED=0 \
    GOOS=linux \
    GOARCH=amd64

# 移动到工作目录：/build
WORKDIR /build

# 将代码复制到容器中
COPY . .

# 将我们的代码编译成二进制可执行文件app
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
    && go build -o app .


FROM alpine:3.19
# 修改服务器的时区
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
    && apk update && apk --no-cache add tzdata \
    && cp -rf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# 把文件拷贝过来
COPY --from=builder /build/app /dist/

# 从builder镜像中把配置文件拷贝到当前目录
COPY ./conf /dist/conf

# 声明端口
#EXPOSE 8888

# 执行命令
ENTRYPOINT ["/dist/app"]